package com.xuanxu.blogs.module.article.controller.app;

import cn.hutool.core.bean.BeanUtil;
import com.xuanxu.blogs.module.article.entity.dao.ArticleClassifyDao;
import com.xuanxu.blogs.module.article.entity.vo.app.ArticleClassifyResponseVo;
import com.xuanxu.blogs.module.article.entity.vo.app.SelectArticleClassifyRequestVo;
import com.xuanxu.blogs.module.article.service.ArticleClassifyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author XuanXu
 * @version 1.0
 * @date 2024-08-30 10:44
 */
@RestController
@RequestMapping("/app-api/article-classify")
@RequiredArgsConstructor
@Api(tags = "文章分类相关接口")
public class AppArticleClassifyController {

    private final ArticleClassifyService articleClassifyService;


    @GetMapping("")
    @ApiOperation("查询文章分类")
    public ResponseEntity<List<ArticleClassifyResponseVo>> selectArticleClassify(SelectArticleClassifyRequestVo selectArticleClassifyRequestVo) {

        ArticleClassifyDao articleClassifyDao = BeanUtil.copyProperties(selectArticleClassifyRequestVo, ArticleClassifyDao.class);
        List<ArticleClassifyDao> articleClassifyDaoList = articleClassifyService.selectArticleClassify(articleClassifyDao);
        List<ArticleClassifyResponseVo> articleClassifyResponseVoList = BeanUtil.copyToList(articleClassifyDaoList, ArticleClassifyResponseVo.class);
        return ResponseEntity.ok(articleClassifyResponseVoList);
    }
}
